package com.ww.learn.oop

enum class Suit { CLUBS, DIAMOND, HEARTS, SPADES }

sealed class Card2(val suit: Suit)

class Ace2(suit: Suit) : Card2(suit)

class King2(suit: Suit) : Card2(suit) {
    override fun toString() = "King of $suit"
}

class Queen2(suit: Suit) : Card2(suit) {
    override fun toString() = "Queen of $suit"
}

class Jack2(suit: Suit) : Card2(suit) {
    override fun toString() = "Jack of $suit"
}

class Pip2(suit: Suit, val number: Int) : Card2(suit) {
    init {
        if (number < 2 || number > 10) {
            throw RuntimeException("Pip has to be between 2 and 10")
        }
    }
}